﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Controls="clr-namespace:PSE.Framework.UI.Controls.SmartClient;assembly=PSE.Framework.UI.Controls"
    xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic">

    <Style TargetType="{x:Type Controls:GroupBox}">
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Padding" Value="7" />
        <Setter Property="Width" Value="200" />
        <Setter Property="Height" Value="200" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Controls:GroupBox}">
                    <Grid SnapsToDevicePixels="true" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                        <Border x:Name="BorderBackground" BorderBrush="{DynamicResource BrushGroupBoxBorder}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="4" OpacityMask="{x:Null}" Background="{DynamicResource BrushGroupBoxBackground}" Margin="0,8,0,0" VerticalAlignment="Stretch"/>
                        <!--Begin Header-->
                        <Border x:Name="Border" Margin="6,0,0,0" CornerRadius="3" Background="{DynamicResource BrushGroupBoxHeaderBackground}" Width="{Binding ElementName=Header, Path=ActualWidth}" HorizontalAlignment="Left" Height="16" VerticalAlignment="Top">
                            <Label x:Name="Header" Content="{TemplateBinding Header}" HorizontalAlignment="Left" Padding="3,1,3,1" Style="{DynamicResource ControlFont}" Foreground="{DynamicResource BrushGroupBoxForeground}"/>    
                        </Border>
                        <!--End Header-->
                        <!--Begin Content-->
                        <ContentPresenter x:Name="Content" Margin="7,23,7,7" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Top"/>
                        <!--End Content-->
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Header" Value="{x:Null}">
                            <Setter Property="Visibility" Value="Hidden" TargetName="Border"/>
                            <Setter Property="Margin" Value="7,15,7,7" TargetName="Content"/>
                        </Trigger>
                        <Trigger Property="Header" Value="">
                            <Setter Property="Visibility" Value="Hidden" TargetName="Border"/>
                            <Setter Property="Margin" Value="7,15,7,7" TargetName="Content"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ControlGroupBoxExpander" TargetType="{x:Type Controls:GroupBox}">
        <Setter Property="BorderBrush" Value="{x:Static Microsoft_Windows_Themes:ClassicBorderDecorator.ClassicBorderBrush}"/>
        <Setter Property="BorderThickness" Value="2"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Controls:GroupBox}">
                    <Grid SnapsToDevicePixels="true">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="11"/>
                            <RowDefinition Height="11"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="6"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="6"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="6"/>
                        </Grid.ColumnDefinitions>
                        <Border Grid.ColumnSpan="4" Grid.Row="2" Grid.RowSpan="2" BorderBrush="{DynamicResource BrushGrupBoxBorderBrush}" BorderThickness="1,0,1,1" CornerRadius="0,0,8,8" >
                        </Border>
                        <Border Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="1" Grid.RowSpan="3" Background="{TemplateBinding Background}" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}">
                        </Border>
                        <Border x:Name="Header" Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" CornerRadius="8,8,0,0" Padding="3,0,3,0" Grid.ColumnSpan="4" Background="{DynamicResource BrushGrupBoxBorderBackGround}" BorderBrush="{DynamicResource BrushGrupBoxBorderBrush}" BorderThickness="1,1,1,0">
                            <Grid>
                                <TextBlock Grid.Row="0" Margin="13,3.5,0,0" Grid.Column="0" Text="{TemplateBinding Header}" FontWeight="Bold" HorizontalAlignment="Left" Foreground="{DynamicResource BrushExpanderTitleForeground}" Style="{DynamicResource ControlFont}"/>
								<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Content="{TemplateBinding HeaderButtons}" ContentTemplate="{TemplateBinding HeaderButtonsTemplate}" RecognizesAccessKey="True" Margin="0,0,18,0" VerticalAlignment="Center" HorizontalAlignment="Right" />
                                <Controls:Button x:Name="ButtonClose" Command="Controls:GroupBox.Close" HorizontalAlignment="Right" Margin="0,0,0,0" Style="{DynamicResource GroupBoxCloseButton}" VerticalAlignment="Center" Content="Button" IsTabStop="False"/>
                            </Grid>
                        </Border>
                        <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="2"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" Value="{DynamicResource BrushGrupBoxBorderDisableBackGround}" TargetName="Header" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="True">
                            <Setter Property="Background" Value="{DynamicResource BrushGrupBoxBorderBackGround}" TargetName="Header" />
                        </Trigger>
                        <Trigger Property="AllowClose" Value="True">
                            <Setter Property="Visibility" Value="Visible" TargetName="ButtonClose"/>
                        </Trigger>
                        <Trigger Property="AllowClose" Value="False">
                            <Setter Property="Visibility" Value="Collapsed" TargetName="ButtonClose"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>


            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>